<template>
	<view class="article_page clearfix">

		<scroll-view class="top" v-if="tableList.length>0" scroll-x="true">
			<!-- tab -->
			<view class="tab">
				<view class="tab_nav" style='font-size:12px'>
					<view class="setTab" v-for="(item, index) in tableList" :key="index"
						:class=" {'active':colunmId == item.id}" @click="ontabtap(item.id)">
						{{item.columnName}}
					</view>
				</view>
			</view>
		</scroll-view>
		<!--end  top-->

		<view class="con_wrap">
			<view class="item clearfix" v-for="(item,index) in contentList" :key="index" @click="goDetail(item.id)">
				<view class="img_wrap">
					<image class="img" :src="item.img" mode="aspectFill"></image>
				</view>
				<view class="r_w">
					<view class="title">{{item.title}}</view>
					<view class="tips">
						<text v-if="item.address">{{item.address}}</text>
						<text v-if="item.type">{{item.type}}</text>
						<text v-if="item.area">{{item.area}}㎡</text>
					</view>
					<view class="level" v-if="item.classifyText">
						{{item.classifyText}}以上专享
					</view>
					<view class="level" v-else>
						不限
					</view>
					<view class="price">
						<text class="pri">￥{{item.predict}}万</text>
						<text style="white-space:nowrap;">
							市场价: <text class="pri">￥{{ item.housePrice}}万</text>
						</text>

					</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="status" v-if="pageSize > 1" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tableList: [],
				colunmId: '',
				tableIndex: 0,
				contentList: [],
				sortStatus: null,
				pageNo: 1,
				pageSize: 0,
				status: 'more',
			}
		},
		onLoad() {
			//获取栏目
			this.getSchoolColumn();
		},
		computed: {
			isHot: function() {
				return this.sortStatus == 1 ? true : false;
			}
		},
		//底部加载更多
		onReachBottom: function() {
			let that = this;
			let query = {};
			let pageNo = this.pageNo + 1;
			query.id = this.colunmId;
			if (pageNo <= this.pageSize) {
				query.pageNo = pageNo;
				that.getMoreData(query)
			} else {
				that.status = "noMore"
			}
		},

		methods: {
			//栏目点击事件
			ontabtap(id) {
				this.colunmId = id;
				let query = {};
				query.id =this.colunmId;
				query.pageNo = 1;
				this.getList(query);

			},
			//查看详细
			goDetail(obj) {
				uni.navigateTo({
					url: '/pages/vipHouse/house_detail?id=' + obj
				});
			},
			//获取栏目
			getSchoolColumn() {
				this.$api.getHouseColumn().then(res => {
					this.tableList = res.data.data;
					this.sortStatus = res.data.data[0].sortStatus;
					let query = {};
					query.id = res.data.data[0].id;
					this.colunmId = res.data.data[0].id;
					this.getList(query);
				})
			},
			//根据条件查询列表
			getList(param) {
				this.$api.getHouseList(param).then(res => {
					this.contentList = res.data.data.records;
					this.pageSize = res.data.data.pages;
				})
			},
			//获取更多数据
			getMoreData(param) {
				this.$api.getHouseList(param).then(res => {
					let data = res.data.data.records;
					if (data) {
						this.contentList = this.contentList.concat(data);
						this.pageSize = res.data.data.pages;
						this.pageNo = res.data.data.current;
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.top {
		width: 100%;
		white-space: nowrap;
		position: fixed;
		top: var(--window-top);
		z-index: 99;
		left: 0;
		background: $dtg-color-primary;

		/deep/.uni-scroll-view {
			border-radius: 20rpx 20rpx 0 0;
			background: #FFFFFF;
		}

		/deep/.uni-scroll-view::-webkit-scrollbar {
			display: none
		}

		.tab {
			display: flex;
			flex-direction: column;
			border-radius: 20rpx 20rpx 0 0;
		}

		.tab_nav {
			height: 80rpx;
			background: #fff;
			display: flex;
			line-height: 79rpx;
			position: relative;
			color: #999999;
			font-size: 28rpx;
		}

		.setTab {
			min-width: 20%;
			max-width: 20%;
			text-align: center;
			height: 80rpx;
			background-color: white;
			font-size: 26rpx;
			position: relative;
		}

		.active {
			color: black;
			font-size: 15px;
			font-weight: bold;
		}

		.active::after {
			content: "";
			width: 40rpx;
			height: 4rpx;
			background: $dtg-color-primary;
			border-radius: 4rpx;
			margin: -4rpx auto;
			display: block;
			animation: roll .23s linear;
		}

		@keyframes roll {
			0% {
				width: 0;
			}

			100% {
				width: 40rpx;
			}
		}

		.con {
			overflow: hidden;
		}
	}
	.clearfix{
		background: #FFFFFF;
	}

	.con_wrap {
		width: 690rpx;
		margin: 100rpx auto 0;
		

		.item {
			margin-bottom: 20rpx;
			width: 100%;
			// background: #FFFFFF;
			border-radius: 20rpx;
			padding: 20rpx 0;
			display: flex;
			justify-content: space-between;
border-bottom: 2rpx solid #F8F8F8;
			.img_wrap {
				width: 210rpx;
				height: 160rpx;
				overflow: hidden;
				margin-right: 32rpx;
			}

			.img {
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
			}

			.r_w {
				flex: 1;
				height: 100%;
				// display: flex;
				// flex-direction: column;
				// justify-content: space-between;

				.title {
					font-size: 32rpx;
					font-weight: bold;
					color: #333333;
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					line-clamp: 1;
					-webkit-box-orient: vertical;
				}

				.tips {
					font-size: 24rpx;
					color: #333333;
					margin: 6rpx 0;

					text {
						margin-right: 20rpx;
					}
				}

				.level {
					background: #EEEEFE;
					color: #585CF7;
					border-radius: 4rpx;
					font-size: 22rpx;
					display: inline-block;
					padding: 4rpx 6rpx;
					margin: 10rpx 0;
				}

				.price {
					font-size: 24rpx;
					display: flex;
					align-items: center;

					.pri {
						font-size: 32rpx;
						color: #FC4073;
						font-weight: bold;
						margin-right: 10rpx;
					}
				}
			}


		}

	}
</style>
<style>
	page {
		background: #F8F8F8;
	}
</style>
